#pragma once
#include "../../protocol/p2pprotocol.hpp"
#include "../../../../include/singleton.h"
#define MAX_PKG_SIZE    1024

class CP2PProtocolImpl :
    public Cp2pprotocol
{
    DECLARE_SINGLETON(CP2PProtocolImpl)
public:
    CP2PProtocolImpl(void);
    virtual ~CP2PProtocolImpl(void);

    virtual void OnRecv_LoginReq(LoginReq& rstProtocol);
    virtual void OnRecv_NATTestReq(NATTestReq& rstProtocol);
    virtual void OnRecv_ConnectPeerReq(ConnectPeerReq& rstProtocol);

    bool HandleClientPkg(char* net_data, int net_size);
    int BuildPkg(void* host, char*& net);
protected:
    char    m_recv_pkg_cache[MAX_PKG_SIZE];
    char    m_send_pkg_cache[MAX_PKG_SIZE];
};
